package com.roc.web.action.windcontroll;

import java.util.ArrayList;
import java.util.List;

import com.roc.page.BaseSearchCondition;
import com.roc.page.WhereHQLFieldBean;
import com.roc.util.Constance;
import com.roc.util.constant.Role;

public class RiskRuleMgrSearchCondition extends BaseSearchCondition{
	
	private String mchtCd;//商户号
	private String riskLevel;//风控等级
	private String posType;//pos类型

	@Override
	protected List<WhereHQLFieldBean> getWhereHQLFieldBeanList() {
		List<WhereHQLFieldBean> filedBeanList = new ArrayList<WhereHQLFieldBean>();
		if(Constance.isNotEmpty(mchtCd)){
			filedBeanList.add(new WhereHQLFieldBean("T.RISK_MCHT_CD", mchtCd.trim(),"=", false));
		}
		if(Constance.isNotEmpty(riskLevel)){
			filedBeanList.add(new WhereHQLFieldBean("T.RISK_LEVEL",riskLevel.trim(),"=",false));
		}
		
		if(Constance.isNotEmpty(posType)){
			if ("1".equals(posType)) {
				filedBeanList.add(new WhereHQLFieldBean(" (t.risk_trans_type like 'POS%' or  t.risk_trans_type like 'ALIPAY%' or t.risk_trans_type like 'WECHAT%' or t.risk_trans_type like 'UNION%') "));
			}else{
				filedBeanList.add(new WhereHQLFieldBean(" t.risk_trans_type like 'MPOS%' "));
			}
		}
		return filedBeanList;
	}

	@Override
	protected String getRowCountHQL() {
		String sql = " SELECT  count(1) FROM apstfr.TBL_MGM_RISK_RULE T  "
				+ "LEFT JOIN TBL_MCHT_INF a ON t.RISK_MCHT_CD = a.MCHT_CD WHERE  T.RISK_USE <> '0' ";
		return sql;
	}

	@Override
	protected String getSearchHQL() {
		String sql = "SELECT  T.RISK_LEVEL,T.RISK_INS_CD,T.RISK_MCHT_CD,T.RISK_TERM_CD,T.RISK_TRANS_TYPE,T.RISK_INFO_TYPE, "
				+ "T.RISK_NUM_CYCLE,T.RISK_KEY_TYPE,T.RISK_NUM_TYPE,T.RISK_NUM_UNITE,T.RISK_NUM_VAULE,T.RISK_USE,a.name "
				+ "FROM apstfr.TBL_MGM_RISK_RULE T  LEFT JOIN TBL_MCHT_INF a ON t.RISK_MCHT_CD = a.MCHT_CD "
				+ "WHERE  T.RISK_USE <> '0'  ";
		return sql;
	}

	@Override
	protected String getOrderPartOfHQL() {
		// TODO Auto-generated method stub
		return " ORDER BY T.RISK_TRANS_TYPE,t.RISK_INFO_TYPE,T.RISK_NUM_CYCLE,T.RISK_KEY_TYPE,T.RISK_NUM_TYPE,T.RISK_NUM_UNITE,T.RISK_NUM_VAULE ";
	}

	public String getMchtCd() {
		return mchtCd;
	}

	public void setMchtCd(String mchtCd) {
		this.mchtCd = mchtCd;
	}

	public String getRiskLevel() {
		return riskLevel;
	}

	public void setRiskLevel(String riskLevel) {
		this.riskLevel = riskLevel;
	}

	public String getPosType() {
		return posType;
	}

	public void setPosType(String posType) {
		this.posType = posType;
	}
	
}
